﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoyoEden.Web.Controls;
using CoyoEden.Models;
using CoyoEden;
using CoyoEden.Web.Controller;
using CoyoEden.Web.Data;

public partial class Views_CategoryPostList :ViewBase,ICallbackEventHandler
{
	public Category CurrentCategory { get; set; }
	protected void Page_Load(object sender, EventArgs e)
	{
		if (PortalSettings.Instance.RenderCategoryView) {
			phCategoryView.Visible = true;
		}
		Page.ClientScript.GetCallbackEventReference(this, "msg", null, string.Empty);
	}

	#region ICallbackEventHandler Members
	private string _feedbackdata;
	public string GetCallbackResult()
	{
		return _feedbackdata;
	}

	public void RaiseCallbackEvent(string eventArgument)
	{
		Dictionary<string, string> Params = null;
		Utils.ToObject<Dictionary<string, string>>(eventArgument, out Params);
		FeedbackData tempData = null;
		//HACK:Using callback event handler to render a view that depending on an instance of System.Web.UI.Page.
		//We can't use webmethod of  webservice to render such a view.Because we can't pass a page instance to a webmethod.
		PostController.SelectPosts(Params, Page, out tempData);
		_feedbackdata = Utils.ToStr<FeedbackData>(tempData);
	}

	#endregion
}
